package com.project.internship.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.internship.entity.Position;
import com.project.internship.entity.StudentPosition;
import com.project.internship.mapper.PositionMapper;
import com.project.internship.mapper.StudentPositionMapper;
import com.project.internship.service.StudentPositionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.internship.utils.UserUtils;
import com.project.internship.utils.YearUtils;
import com.project.internship.vo.StudentPositionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2020-04-14
 */
@Service
public class StudentPositionServiceImpl extends ServiceImpl<StudentPositionMapper, StudentPosition> implements StudentPositionService {

    @Autowired
    StudentPositionMapper spMapper;
    @Autowired
    PositionMapper positionMapper;

    @Override
    public IPage<StudentPositionVO> getStudentToPosition(Page<StudentPositionVO> page, String keyword) {
        return spMapper.getStudentToPosition(page, UserUtils.getCurrentUser().getBaseId(),YearUtils.getCurrentYear(),keyword);
    }

    @Override
    public Integer addStudentPosition(StudentPosition studentPosition) {
        return spMapper.insert(studentPosition);
    }

    @Override
    public Integer updateStudentPosition(StudentPosition studentPosition) {
        return spMapper.updateById(studentPosition);
    }

    @Override
    public IPage<StudentPositionVO> getPracticeRecord(Page<StudentPositionVO> page, String keyword) {
        return spMapper.getPracticeRecord(page, UserUtils.getCurrentUser().getBaseId(),keyword);
    }
}
